package com.mapbar.ure.frontend.parser;

import java.util.List;

import com.mapbar.ure.ProductionType;

/**
 * 对RE形成的抽象语法树，作为中间形态方便实施Thompson算法。
 * 
 * @author qin
 * 
 */
public class AST<T> {
	private ProductionType type;
	private T value;
	private List<AST<T>> children;

	public AST(ProductionType type, T value) {
		this.type = type;
		this.value = value;
	}

	public AST(ProductionType type, List<AST<T>> children) {
		this.type = type;
		this.children = children;
	}

	public ProductionType getType() {
		return type;
	}

	public void setType(ProductionType type) {
		this.type = type;
	}

	public T getValue() {
		return value;
	}

	public void setValue(T value) {
		this.value = value;
	}

	public List<AST<T>> getChildren() {
		return children;
	}

	public void setChildren(List<AST<T>> children) {
		this.children = children;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(type);
		sb.append('/');
		sb.append(value);
		sb.append('\n');
		return sb.toString();
	}

}
